package com.mm.cme.kotlin_001.level02.i_002_branch_expression

import com.mm.cme.kotlin_001.utils.pl

/**
 * Descriptions：if表达式
 * <p>
 * Author：ChenME
 * Date：2017/7/16
 * Email：ibelieve1210@163.com
 */
private const val USER_NAME = "kotlin"
private const val PASSWORD = "java"

private const val ADMIN_USER = "admin"
private const val ADMIN_PASSWORD = "admin"

private const val DEBUG = 1
private const val USER = 0

fun main(args: Array<String>) {

    val mode = if (args.isNotEmpty() && args[0] == "1") {
        DEBUG
    } else {
        USER
    }

    pl("请输入用户名：")
    val str_userName = readLine()
    pl("请输入密码：")
    val str_pwd = readLine()

    if (DEBUG == mode && ADMIN_USER == str_userName && ADMIN_PASSWORD == str_pwd) {
        pl("管理员登陆成功！")
    } else if (USER_NAME == str_userName && PASSWORD == str_pwd) {
        pl("登陆成功！")
    } else {
        pl("登录失败！")
    }
}